﻿package com.wjp.utils;


import java.util.ArrayList;
import java.util.List;

/**
 * 工具类
 */
public class Utils {
	/**
	 * 验证用户名是否可用
	 */
	public static boolean isUserName(String userName) {
		String regx = "(^[a-zA-Z0-9_-]{6,16}$)|(^[\u2E80-\u9FFF]{2,5})";
		//用户名必须是6-16位数字和字母的组合或者2-5位中文
		return userName.matches(regx);
	}
	/**
	 * 批量int id转成数组
	 */
	public static List<Integer> isIntegerIds(String ids){
		List<Integer>  del_ids = new ArrayList<Integer>();
		if(ids.contains("-")){
			String[] str_ids = ids.split("-");
			for (String string : str_ids) {
				del_ids.add(Integer.parseInt(string));
			}
		}else  if(ids.contains(",")){
			String[] str_ids = ids.split(",");
			for (String string : str_ids) {
				del_ids.add(Integer.parseInt(string));
			}
		}
		return  del_ids;
	}
	/**
	 * 批量String id转成数组
	 */
	public static List<String> isStringIds(String ids){
		List<String>  del_ids = new ArrayList<String>();
		if(ids.contains("-")){
			String[] str_ids = ids.split("-");
			for (String string : str_ids) {
				del_ids.add(string);
			}
		}
		return  del_ids;
	}
	
	
	public static boolean isNull(Object obj) {
		if (obj != null) {
			if (obj instanceof String) {
				if (!"".equals(obj.toString().trim())) {
					return false;
				}
			} else {
				return false;
			}
			return true;
		}
		return true;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
}